package com.zyh.demo;

import java.util.Scanner;

public class StringDemo3 {
    public static void main(String[] args) {
        /*Test test = new Test();
        String s = test.returnArray();
        System.out.println("反转的字符串："+s);*/
        InterStringDemo3 inter=new InterStringDemo3() {
            @Override
            public String returnArray() {
                System.out.println("请输入一个字符串：");
                String str = new Scanner(System.in).next();
                System.out.println("录入的字符串："+str);
                char[] chs = str.toCharArray();
                for (int start=0,end=chs.length-1;start<=end;start++,end--){
                    char temp = chs[start];
                    chs[start]=chs[end];
                    chs[end]=temp;
                }
                String newStr = new String(chs);
                return newStr;
            }
        };
        String s = inter.returnArray();
        System.out.println("反转的字符串："+s);
    }

}
class Test implements InterStringDemo3{
    @Override
    public String returnArray() {
        System.out.println("请输入一个字符串：");
        String str = new Scanner(System.in).next();
        System.out.println("录入的字符串："+str);
        char[] chs = str.toCharArray();
        for (int start=0,end=chs.length-1;start<=end;start++,end--){
            char temp = chs[start];
            chs[start]=chs[end];
            chs[end]=temp;
        }
        String newStr = new String(chs);
        return newStr;
    }
}
